package com.neuedu.yyzx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.common.CommonResult;
import com.neuedu.yyzx.entity.NurseLevelContent;
import com.neuedu.yyzx.service.INurseLevelContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 护理级别对应的护理内容 前端控制器
 * </p>
 *
 * @author dya
 * @since 2021-04-27
 */
@RestController
@RequestMapping("//nurseLevelContent")
public class NurseLevelContentController {
    @Autowired
    INurseLevelContentService nurseLevelContentService;
    @RequestMapping("/list")
    CommonResult list(Page page, NurseLevelContent nurseLevelContent){
        QueryWrapper queryWrapper = new QueryWrapper();
        if(nurseLevelContent!= null && StringUtils.isNotEmpty(nurseLevelContent.getNurseContent())){
            queryWrapper.like("nurse_content",nurseLevelContent.getNurseContent());
        }
        return CommonResult.success(nurseLevelContentService.page(page,queryWrapper));
    }

    @RequestMapping("/add")
    CommonResult add(NurseLevelContent nurseLevelContent){
        return CommonResult.success(nurseLevelContentService.saveOrUpdate(nurseLevelContent));
    }

    @RequestMapping("/update")
    CommonResult update(NurseLevelContent nurseLevelContent){
        return CommonResult.success(nurseLevelContentService.updateAll(nurseLevelContent));
    }

    @RequestMapping("/getById")
    CommonResult getById(Integer id){
        return CommonResult.success(nurseLevelContentService.getById(id));
    }

    @RequestMapping("/del")
    CommonResult del(Integer id){
        return CommonResult.success((nurseLevelContentService.removeById(id)));
    }
}
